;----------------------------------------------------------------------------
; FileName: Fis.asm
; This program is uesed to extrace finger minutiae and detect fingertip
; The function call image process routines,such as image normalize,image     
; binary,image thining,minutiae extrce and finger match data                 
; Written by : wang zhigang 
; Date   : 20/6/2000
;----------------------------------------------------------------------------
                .mmregs       
                .include "fisc54.inc"

;               .ref    RegionMask1,RegionMask2,LastRegion,AdjustDtrDcr
                .ref    ImageNormal,FilterRing,ThinImage
                .ref    RegionMask,AdjustMask1,AdjustMask2,AdjustMask3
                .ref    OrientImage,SmoothTangle,QuantizeTheta
                .ref    CalFrequency,SmoothFreq,Divisor
                .ref    MinutiaeExtract,FinalMinutiae,MatchData
                .def    ThetaArray,FreqArray,LightArray
;----------------------------------------------------------------------------
ThetaArray      .usect "finger_bfr",BLOCKNUM
LightArray      .usect "finger_bfr",BLOCKNUM
FreqArray       .usect "finger_bfr",BLOCKNUM
SystemStack     .usect "stack_bfr" ,255

;-----------------------------------------------------------------------------			    
                .sect   "vectors"
reset:          BD      MAIN_START ;chip reset interrupt
                NOP
                NOP
;----------------------------------------------------------------------------
                .text
MAIN_START:
                RSBX    SXM
                RSBX    OVM
                SSBX    INTM
				RSBX	CPL
                STM     #SystemStack+0ffh,SP
                STM     #7effh,SWWSR
                ANDM    #0ffh,PMST 
                RPT     #10
                NOP
                LD      #Divisor,DP
;               CALL    AdjustDtrDcr
                CALL    ImageNormal
                CALL    RegionMask
;               CALL    RegionMask1
;               CALL    RegionMask2
                CALL    AdjustMask1
                CALL    OrientImage
                CALL    AdjustMask2
                CALL    SmoothTangle
                CALL    QuantizeTheta
                CALL    CalFrequency
                SSBX    SXM
                STM     #FreqArray,AR6
                SUB     B,B
                STM     #BLOCKNUM-1,BRC
                RPTB    CHECK_FREQ_LEN-1
                LD      *AR6+,A
                ADD     #1,A
                BC      NO_INCLEN,AEQ
                ADD     #1,B
NO_INCLEN
                NOP
CHECK_FREQ_LEN
                RSBX    SXM
                SUB     #20,B
                BC      STOP_HERE,BLT
                CALL    SmoothFreq
                CALL    FilterRing
                CALL    ThinImage
;               CALL    LastRegion
                CALL    AdjustMask3
                CALL    AdjustMask2
                CALL    MinutiaeExtract
                CALL    FinalMinutiae
				SSBX    SXM
                CALL    MatchData
				RSBX    SXM
				BC      DETECT_FINGER,TC
STOP_HERE:
                IDLE 1
DETECT_FINGER
                B STOP_HERE

;----------------------------------------------------------------------------
                .end 
